package org.example.application;

import org.example.model.po.SysOrderPO;
import org.example.model.po.SysStockPO;
import org.example.repository.SysOrderRepository;
import org.example.repository.SysStockRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author shenguangyang
 */
@Service
public class OrderApplication {
    @Resource
    private SysOrderRepository sysOrderRepository;

    @Resource
    private SysStockRepository sysStockRepository;

    /**
     * 下单 减库存
     */
    public void saveOrder() {
        sysOrderRepository.save(SysOrderPO.builder()
                .userId(1L).serialNumber(UUID.randomUUID().toString())
                .goodsName("商品1").goodsId(1L).build());

        SysStockPO sysStockPO = SysStockPO.builder().goodsId(1L).build();
        sysStockRepository.updateStock(sysStockPO);
    }
}
